﻿using CatUtils.Utils.Currency.IoUtils;
using CatUtils.Utils.SpecialUtils.PicBed.Sina;
using System;
using System.Collections.Generic;

namespace SinaImgUpload.SainTool.LocalTool
{
    internal class FolderToList
    {
        /// <summary>
        /// 上传文件夹，包括子文件夹。
        /// </summary>
        /// <param name="FloderPath"></param>
        public void UploadChildFloder(string FloderPath)
        {
            List<string> GetChildFoloder = FloderNameHelper.GetFloderNameList(FloderPath);
            int UploadCount = 0;
            foreach (string SingleFloder in GetChildFoloder)
            {
                Console.WriteLine(SingleFloder);
                Console.WriteLine("已上传{0}篇文章,总量{1}，百分比{2}%", UploadCount++, GetChildFoloder.Count, (float)UploadCount / GetChildFoloder.Count * 100);
                UploadSingleFloder(SingleFloder);
                FloderHelper.FolderDelete(SingleFloder);
            }
        }

        /// <summary>
        /// 上传单个文件夹
        /// </summary>
        /// <param name="SingleFloder"></param>
        public void UploadSingleFloder(string SingleFloder)
        {
            List<string> TempImgLiST = UploadUtils.UploadFloder(SingleFloder, 6000);
            string SaveListPath = FloderNameHelper.GetFloderPath(SingleFloder) + FloderNameHelper.GetFloderName(SingleFloder) + ".lst";
            Console.WriteLine("保存{0}", SaveListPath);

            FileHelper.WriteList(SaveListPath, TempImgLiST);
        }
    }
}